/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.punishinform.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.common.core.Validator.BaseGroup;
import com.icinfo.cloud.provider.punish.ucase.punishinform.dto.InformHtmlRequest;
import com.icinfo.cloud.provider.punish.ucase.punishinform.dto.PunishInformFormDto;
import com.icinfo.cloud.provider.punish.ucase.punishinform.service.IPunishInformService;
import com.icinfo.cloud.provider.punish.ucase.punishinform.vo.PunishInformFormVo;
import com.icinfo.cloud.workflow.work.service.IWorkFlowRollAutoexcuteRecordService;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 【V1.3.1】描述:  处罚告知对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年02月13日
 */
@RestController
@RequestMapping("/punish/inform")
public class PunishInformController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(PunishInformController.class);

    @Autowired
    private IPunishInformService iInformService;
    @Autowired
    private IWorkFlowRollAutoexcuteRecordService workFlowRollAutoexcuteRecordService;

    /**
     * 【V1.0.0】描述：获取处罚告知表单数据
     *
     * @param request
     * @return {@link Result<PunishInformFormVo>}
     * @author liyafeng
     * @date 2022/2/16
     */
    @PostMapping(value = "/getPunishInformFormBaseinfo", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<PunishInformFormVo> getPunishInformFormBaseinfo(@RequestBody @Validated(BaseGroup.Query.class) InformHtmlRequest request) {
        return Result.success(iInformService.getPunishInformFormBaseinfo(request));
    }

    /**
     * 【V1.0.0】描述：保存处罚告知表单数据
     *
     * @param dto
     * @return {@link Result<String>}
     * @author liyafeng
     * @date 2022/2/17
     */
    @PostMapping(value = "/savePunishInformForm", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<String> savePunishInformForm(@RequestBody PunishInformFormDto dto) {
        if (iInformService.savePunishInformForm(dto) < 1) {
            return Result.error("保存失败");
        }
        return Result.success("保存成功");
    }


    /**
     * 【V1.3.1】描述： 查询是否符合听证条件
     *
     * @author: zhengqiang
     * @date: 2022/7/11
     * @param: punishInformFormDto
     * @return {@link Result< String>}
     **/
    @PostMapping(value = "/getIsNeedHearingResult")
    public Result<String> getIsNeedHearingResult(@RequestBody PunishInformFormDto punishInformFormDto){
        return iInformService.getIsNeedHearingResult(punishInformFormDto);
    }

    /**
     * 手动调用处罚告知滚动
     */
    @GetMapping(value = "/doExecuteWorkFlow")
    public void doExecuteWorkFlow(){
        System.out.println("===================手动执行告知流程滚动任务开始=======================");
        workFlowRollAutoexcuteRecordService.doExcuteAutomaticWorkFlow(Constant.EXECUTE_PUNISHINFORM_SENT);
        System.out.println("===================手动执行告知流程滚动任务结束=======================");
    }
}